<template>
  <EvDialog
    :title="'布局模型'"
    :dialogVisible="dialogVisible"
    width="50%"
    :close-on-click-modal="false"
    :modal-append-to-body="false"
    :append-to-body="true"
    @handleClose="handleDialogClose"
    @handleCancel="handleDialogCancel"
    @handleConfirm="handleDialogConfirm"
  >
    <el-form>
      <el-row>
        <el-col :span="24">
          <el-form label-width="80px" :model="layoutForm" :rules="rules">
            <el-form-item label="模型编号" required prop="code">
              <el-input v-model="layoutForm.code"></el-input>
            </el-form-item>
            <el-form-item label="模型名称" required prop="name">
              <el-input v-model="layoutForm.name"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </el-form>
  </EvDialog>
</template>
  <script>
import EvDialog from "@/components/EvDialog/index.vue";
export default {
  components: {
    EvDialog,
  },
  data() {
    return {
      dialogVisible: false,
      layoutForm: {
        name: "",
        code: "",
      },
      rules: {
        name: [{ required: true, message: "请输入模型名称", trigger: "blur" }],
        code: [{ required: true, message: "请输入模型编号", trigger: "blur" }],
      },
      addOrEdit: "add",
    };
  },
  methods: {
    open(form) {
      if (form) {
        this.addOrEdit = "edit";
        this.layoutForm = form;
      } else {
        this.addOrEdit = "add";
        this.layoutForm = {
          name: "",
          code: "",
        };
      }
      this.dialogVisible = true;
    },
    handleDialogCancel() {
      this.dialogVisible = false;
    },
    handleDialogClose() {
      this.dialogVisible = false;
    },
    handleDialogConfirm() {
      this.$server()
        .add("function-quality", "JsonFormData", this.layoutForm)
        .then(() => {
          this.$message.success("新增成功");
          this.dialogVisible = false;
        })
        .catch((response) => {
          this.$message.error(response.data.message);
        });
    },
  },
};
</script>
  <style lang="scss" scoped>
</style>
  